import React, {createContext} from "react";

export const  ThemeContext = createContext();//通过createContext方法可以创建多个context

class ThemeProvider extends React.Component{
    state = {
        color:"green"
    }
    changeColor = () => {
        this.setState({
            color:"blue"
        })
    }
    render() {
        return <ThemeContext.Provider value={{color:this.state.color,changeColor:this.changeColor}}>
            {this.props.children}
        </ThemeContext.Provider>
    }
}

export default ThemeProvider;